package io.github.talelin.latticy.controller.v1;

import io.github.talelin.core.annotation.GroupRequired;
import io.github.talelin.core.annotation.PermissionMeta;
import io.github.talelin.core.annotation.PermissionModule;
import io.github.talelin.latticy.dto.problem.ProblemCreateDTO;
import io.github.talelin.latticy.dto.problem.ProblemPageDTO;
import io.github.talelin.latticy.dto.problem.ShelfDTO;
import io.github.talelin.latticy.service.ProblemService;
import io.github.talelin.latticy.vo.CreatedVO;
import io.github.talelin.latticy.vo.FindResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName：ProblemController
 * @Author: ljj
 * @Date: 2022/8/17 16:04
 */
@RestController
@RequestMapping("/v1/problem")
@PermissionModule(value = "问题件管理")
public class ProblemController {

    @Autowired
    private ProblemService problemService;

    @PermissionMeta(value = "问题件标记")
    @GroupRequired
    @PostMapping("/mark")
    public CreatedVO mark(@RequestBody ProblemCreateDTO problemCreateDTO){
        problemService.mark(problemCreateDTO);
        return new CreatedVO();
    }

    @PermissionMeta(value = "问题件查询")
    @GroupRequired
    @PostMapping("/pageList")
    public FindResultVO pageList(@RequestBody ProblemPageDTO problemPageDTO){
        return problemService.pageList(problemPageDTO);
    }


    @GetMapping("/dealWith/{orderNo}")
    public FindResultVO dealWith(@PathVariable Long orderNo){
        return FindResultVO.success(problemService.dealWith(orderNo));
    }

    @PostMapping("/shelf")
    public CreatedVO shelf(@RequestBody ShelfDTO shelfDTO){
        problemService.shelf(shelfDTO);
        return new CreatedVO();
    }
}
